﻿<%@ Page Title="" Language="C#" ValidateRequest="false" MasterPageFile="~/Content/Home.Master" Inherits="System.Web.Mvc.ViewPage<MailBroadcastCore.Models.Collection.CreateCampaignCollection>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	NewCampaign
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <style type="text/css">
    .hidden {
    display: none;
    }
    </style>
    <link rel="stylesheet" type="text/css" href="../../Content/jquery-ui.css" />
    <script type="text/javascript" src="/Scripts/jquery.min.js"></script>
    <script type="text/javascript" src="/Scripts/jquery-ui.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $(".tabmenu").removeClass("hidden");
            $(".tabs h2").addClass("hidden");
            $(".tabs").tabs();
        });
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            var chooseClientID = $("#ClientID_CampaignDetail_validationMessage").html();
            var chooseClientStaff = $("#ArrayStaffClientID_validationMessage").html();
            var chooseTitleCampaign = $("#Name_CampaignDetail_validationMessage").html();
            var chooseUserNameSetting = $("#UserName_MailSettingDetail_validationMessage").html();
            var choosePasswordSetting = $("#Password_MailSettingDetail_validationMessage").html();
            var choosePort = $("#SMTPPort_MailSettingDetail_validationMessage").html();
            var chooseApplyTemplate = $("#Content_TemplateDetailValueINOUT_validationMessage").html();
            var chooseScheduleName = $("#ScheduleName_ScheduleDetail_validationMessage").html();

            var tab1s = $("#tab1s");
            var tab2s = $("#tab2s");
            var tab3s = $("#tab3s");
            var tab4s = $("#tab4s");
            var tab5s = $("#tab5s");
            var tab6s = $("#tab6s");

            tab2s.addClass("hidden");
            tab3s.addClass("hidden");
            tab4s.addClass("hidden");
            tab5s.addClass("hidden");
            tab6s.addClass("hidden");

        });
        function CheckFirst() {
            if (document.all || document.getElementById) {
                document.getElementById('checkFirst').value = "true";
            }
            else {
                document.getElementById('checkFirst').setAttribute("value", "true");
            }
        }
        function CheckDetailClick() {
            var checkFirsts = document.getElementById("checkFirst").value;

            if (checkFirsts.toString() != "true") {
                return;
            }

            var check = false;
            var btnSaveDetail = $("#btnSaveDetail");
            var btnSaveMailSetting = $("#btnSaveMailSetting");
            var btnSaveAttachFile = $("#btnSaveAttachFile");
            var btnSaveTemplate = $("#btnSaveTemplate");
            var btnSaveCustomerList = $("#btnSaveCustomerList");

            var chooseClientID = $("#ClientID_CampaignDetail_validationMessage").html();
            var chooseClientStaff = $("#ArrayStaffClientID_validationMessage").html();
            var chooseTitleCampaign = $("#Name_CampaignDetail_validationMessage").html();

            var chooseUserNameSetting = $("#UserName_MailSettingDetail_validationMessage");
            var choosePasswordSetting = $("#Password_MailSettingDetail_validationMessage");
            var choosePort = $("#SMTPPort_MailSettingDetail_validationMessage");

            var tab1s = $("#tab1s");
            var tab2s = $("#tab2s");
            var tab3s = $("#tab3s");
            var tab4s = $("#tab4s");
            var tab5s = $("#tab5s");
            var tab6s = $("#tab6s");

            var div1s = $("#tab-1");
            var div2s = $("#tab-2");
            var div3s = $("#tab-3");
            var div4s = $("#tab-4");
            var div5s = $("#tab-5");
            var div6s = $("#tab-6");

            if (chooseClientID.toString().indexOf("<span") != -1) {
                check = false;
            }
            else
                check = true;

            if (chooseClientStaff.toString().indexOf("<span") != -1) {
                check = false;
            }
            else
                check = true;

            if (chooseTitleCampaign.toString().indexOf("<span") != -1) {
                check = false;
            }
            else
                check = true;


            if (check) {

                tab1s.removeClass("ui-tabs-selected ui-state-active");
                div1s.addClass("ui-tabs-hide");

                tab2s.removeClass("hidden");
                tab2s.addClass("ui-tabs-selected ui-state-active");
                div2s.removeClass("ui-tabs-hide");

                tab3s.addClass("hidden");
                tab4s.addClass("hidden");
                tab5s.addClass("hidden");
                tab6s.addClass("hidden");
                btnSaveDetail.addClass("hidden");
                btnSaveMailSetting.removeClass("hidden");

                chooseUserNameSetting.addClass("hidden");
                choosePasswordSetting.addClass("hidden");
                choosePort.addClass("hidden");
            }

        }
        function CheckMailSettingClick() {
            var check = false;
            var btnSaveDetail = $("#btnSaveDetail");
            var btnSaveMailSetting = $("#btnSaveMailSetting");
            var btnSaveAttachFile = $("#btnSaveAttachFile");
            var btnSaveTemplate = $("#btnSaveTemplate");
            var btnSaveCustomerList = $("#btnSaveCustomerList");

            var chooseUserNameSettings = $("#UserName_MailSettingDetail_validationMessage");
            var choosePasswordSettings = $("#Password_MailSettingDetail_validationMessage");
            var choosePorts = $("#SMTPPort_MailSettingDetail_validationMessage");

            chooseUserNameSettings.removeClass("hidden");
            choosePasswordSettings.removeClass("hidden");
            choosePorts.removeClass("hidden");

            var chooseUserNameSetting = $("#UserName_MailSettingDetail_validationMessage").html();
            var choosePasswordSetting = $("#Password_MailSettingDetail_validationMessage").html();
            var choosePort = $("#SMTPPort_MailSettingDetail_validationMessage").html();
            var tab1s = $("#tab1s");
            var tab2s = $("#tab2s");
            var tab3s = $("#tab3s");
            var tab4s = $("#tab4s");
            var tab5s = $("#tab5s");
            var tab6s = $("#tab6s");

            var div1s = $("#tab-1");
            var div2s = $("#tab-2");
            var div3s = $("#tab-3");
            var div4s = $("#tab-4");
            var div5s = $("#tab-5");
            var div6s = $("#tab-6");

            if (chooseUserNameSetting.toString().indexOf("<span") != -1) {
                check = false;
            }
            else
                check = true;

            if (choosePasswordSetting.toString().indexOf("<span") != -1) {
                check = false;
            }
            else
                check = true;

            if (choosePort.toString().indexOf("<span") != -1) {
                check = false;
            }
            else
                check = true;


            if (check) {

                tab2s.removeClass("ui-tabs-selected ui-state-active");
                div2s.addClass("ui-tabs-hide");

                tab3s.removeClass("hidden");
                tab3s.addClass("ui-tabs-selected ui-state-active");
                div3s.removeClass("ui-tabs-hide");
                
                tab4s.addClass("hidden");
                tab5s.addClass("hidden");
                tab6s.addClass("hidden");
                btnSaveMailSetting.addClass("hidden");
                btnSaveAttachFile.removeClass("hidden");
            }

        }
        function CheckAttachFileClick() {
            var check = false;
            var btnSaveDetail = $("#btnSaveDetail");
            var btnSaveMailSetting = $("#btnSaveMailSetting");
            var btnSaveAttachFile = $("#btnSaveAttachFile");
            var btnSaveTheme = $("#btnSaveTheme");
            var btnSaveCustomerList = $("#btnSaveCustomerList");

            var chooseApplyTemplates = $("#Content_TemplateDetailValueINOUT_validationMessage");

            var tab1s = $("#tab1s");
            var tab2s = $("#tab2s");
            var tab3s = $("#tab3s");
            var tab4s = $("#tab4s");
            var tab5s = $("#tab5s");
            var tab6s = $("#tab6s");

            var div1s = $("#tab-1");
            var div2s = $("#tab-2");
            var div3s = $("#tab-3");
            var div4s = $("#tab-4");
            var div5s = $("#tab-5");
            var div6s = $("#tab-6");

                tab3s.removeClass("ui-tabs-selected ui-state-active");
                div3s.addClass("ui-tabs-hide");

                tab4s.removeClass("hidden");
                tab4s.addClass("ui-tabs-selected ui-state-active");
                div4s.removeClass("ui-tabs-hide");

                tab5s.addClass("hidden");
                tab6s.addClass("hidden");
                btnSaveAttachFile.addClass("hidden");
                btnSaveTheme.removeClass("hidden");

                chooseApplyTemplates.addClass("hidden");

            }
            function CheckTemplateClick() {
                var check = false;
                var btnSaveDetail = $("#btnSaveDetail");
                var btnSaveMailSetting = $("#btnSaveMailSetting");
                var btnSaveAttachFile = $("#btnSaveAttachFile");
                var btnSaveTheme = $("#btnSaveTheme");
                var btnSaveCustomerList = $("#btnSaveCustomerList");

                var chooseApplyTemplates = $("#Content_TemplateDetailValueINOUT_validationMessage");
                chooseApplyTemplates.removeClass("hidden");

                var chooseApplyTemplate = $("#Content_TemplateDetailValueINOUT_validationMessage").html();

                var tab1s = $("#tab1s");
                var tab2s = $("#tab2s");
                var tab3s = $("#tab3s");
                var tab4s = $("#tab4s");
                var tab5s = $("#tab5s");
                var tab6s = $("#tab6s");

                var div1s = $("#tab-1");
                var div2s = $("#tab-2");
                var div3s = $("#tab-3");
                var div4s = $("#tab-4");
                var div5s = $("#tab-5");
                var div6s = $("#tab-6");

                if (chooseApplyTemplate.toString().indexOf("<span>") != -1) {
                    check = false;
                }
                else
                    check = true;

               
                if (check) {

                    tab4s.removeClass("ui-tabs-selected ui-state-active");
                    div4s.addClass("ui-tabs-hide");

                    tab5s.removeClass("hidden");
                    tab5s.addClass("ui-tabs-selected ui-state-active");
                    div5s.removeClass("ui-tabs-hide");
                                       
                    tab6s.addClass("hidden");
                    btnSaveTheme.addClass("hidden");
                    btnSaveCustomerList.removeClass("hidden");
                }

            }
            function CheckCustomerListClick() {
                var check = false;
                var btnSaveCustomerList = $("#btnSaveCustomerList");
                var btnSave1 = $("#btnSave1");
                var btnSave = $("#btnSave");
//                var chooseScheduleName = $("#ScheduleName_ScheduleDetail_validationMessage").html();

                var tab1s = $("#tab1s");
                var tab2s = $("#tab2s");
                var tab3s = $("#tab3s");
                var tab4s = $("#tab4s");
                var tab5s = $("#tab5s");
                var tab6s = $("#tab6s");

                var div1s = $("#tab-1");
                var div2s = $("#tab-2");
                var div3s = $("#tab-3");
                var div4s = $("#tab-4");
                var div5s = $("#tab-5");
                var div6s = $("#tab-6");

               
                    tab5s.removeClass("ui-tabs-selected ui-state-active");
                    div5s.addClass("ui-tabs-hide");

                    tab6s.removeClass("hidden");
                    tab6s.addClass("ui-tabs-selected ui-state-active");
                    div6s.removeClass("ui-tabs-hide");

                    btnSaveCustomerList.addClass("hidden");
                    btnSave1.addClass("hidden");
                    btnSave.removeClass("hidden");
               
            }
         </script>
    <% Html.EnableClientValidation(); %> 
    
    <% using (Html.BeginForm("SaveAddCampaignCreate", "Campaign",FormMethod.Post, new { enctype = "multipart/form-data" }))
            {%>
            <div>   
                <center><h2>New Campaign</h2></center>
                <% if (ViewData["old"] != null) { 
                   %>
                    <p><%=ViewData["old"] %></p>
                   <%
                   } %>         
                <div class="tabs">
                    <ul class="tabmenu hidden">
                    <li id="tab1s"><a href="#tab-1">Detail</a></li>
                    <li id="tab2s"><a href="#tab-2">Email Setting</a></li>
                    <li id="tab3s"><a href="#tab-3">Attach File</a></li>
                    <li id="tab4s"><a href="#tab-4">Template</a></li>
                    <li id="tab5s"><a href="#tab-5">Customer List</a></li>
                    <li id="tab6s"><a href="#tab-6">Schedule</a></li>
                    </ul>
                <div id="tab-1">
                <h2>Detail</h2>
                <p><%=Html.Action("CampaignCreateDetails") %></p>
                </div>
                <div id="tab-2">
                <h2>Mail Setting</h2>
                <p><%=Html.Action("CampaignCreateMailSetting")%></p>
                </div>
                <div id="tab-3">
                <h2>Attach File</h2>
                <p><%=Html.Action("CampaignCreateAttachFile")%></p>
                </div>
                <div id="tab-4">
                <h2>Template</h2>
                <p><%=Html.Action("CampaignCreateTemplate")%></p>
                </div>
                <div id="tab-5">
                <h2>Customer List</h2>
                <p><%=Html.Action("CampaignCreateCustomerList")%></p>
                </div>
                <div id="tab-6">
                <h2>Schedule</h2>
                <p><%=Html.Action("CampaignCreateSchedule")%></p>
                </div>
                </div>
                
            </div>
            
            <div>
             <input id="checkFirst" type="hidden" value="false" />
             <input id="btnSave1" type="submit" value="Save" onclick="CheckFirst();" class="button themed" />
             <input id="btnSaveDetail" type="submit" value="Next" onclick="CheckDetailClick();" class="button themed" />
             <input id="btnSaveMailSetting" type="submit" value="Next" onclick="CheckMailSettingClick();" class="button themed hidden" />
             <input id="btnSaveAttachFile" type="submit" value="Next" onclick="CheckAttachFileClick();" class="button themed hidden" />
             <input id="btnSaveTheme" type="submit" value="Next" onclick="CheckTemplateClick();" class="button themed hidden" />
             <input id="btnSaveCustomerList" type="submit" value="Next" onclick="CheckCustomerListClick();" class="button themed hidden" />
             <input id="btnSave" type="submit" value="Save" class="button themed hidden" />

             Note: Please Click "Save" and then click "Next"
            </div>
            <div>
                 <div id="divError">
                    <p>
                        <span style="color:Red;font-weight:bold"><%=ViewData["Result"]%></span>
                    </p>                 
                 </div>
                 
            </div>

    <% } %>
</asp:Content>
